﻿Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Runtime.Serialization
Imports System.Workflow.ComponentModel.Design

Namespace System.Workflow.Activities
    <Serializable> _
    Friend NotInheritable Class InvokeWebServiceToolboxItem
        Inherits ActivityToolboxItem
        ' Methods
        Public Sub New(ByVal type As Type)
            MyBase.New(type)
        End Sub

        Private Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            MyBase.Deserialize(info, context)
        End Sub

        Public Overrides Function CreateComponentsWithUI(ByVal host As IDesignerHost) As IComponent()
            Dim url As Uri = Nothing
            Dim proxyClass As Type = Nothing
            Dim service As IExtendedUIService = [TryCast](host.GetService(GetType(IExtendedUIService)),IExtendedUIService)
            If (Not service Is Nothing) Then
                service.AddWebReference(url, proxyClass)
            End If
            Dim componentArray As IComponent() = MyBase.CreateComponentsWithUI(host)
            If (componentArray.GetLength(0) > 0) Then
                Dim activity As InvokeWebServiceActivity = [TryCast](componentArray(0),InvokeWebServiceActivity)
                If (Not activity Is Nothing) Then
                    activity.ProxyClass = proxyClass
                End If
            End If
            Return componentArray
        End Function

    End Class
End Namespace

